package com.yantong.service;

import com.yantong.pojo.*;
import com.yantong.pojo.vo.MemberCartVo;
import com.yantong.pojo.vo.TicketVo;
import com.yantong.utils.PageUtils;

import java.util.List;
import java.util.Map;

/**
 * 优惠券服务
 *
 * @author kanghaixin
 * @date 2018/9/25.11:22
 */
public interface TicketService {
    /**
     * 优惠券列表
     *
     * @param queryItem
     * @param centreId
     * @param status
     * @param offset
     * @param limit
     * @return
     */
    PageUtils<Ticket> listTickets(String queryItem, Long centreId, Long teamId, Integer status, int offset, int limit);

    /**
     * 优惠券列表
     *
     * @param queryItem
     * @param centreId
     * @param status
     * @param offset
     * @param limit
     * @return
     */
    PageUtils<Ticket> listTickets(String queryItem, Long centreId, Integer status, int offset, int limit);

    //添加优惠券使用记录
    Long addRecordUseInfo(TicketRecord ticket, Integer countUse, Long refId, String remark, TicketRecordUse ticketRecordUse);

    /**
     * 优惠券新增
     *
     * @param ticket
     * @return
     */
    int saveTicket(Ticket ticket);

    /**
     * 优惠券详情
     *
     * @param ticketId
     * @return
     */
    Ticket getByKey(Long ticketId);

    /**
     * 优惠券编辑保存
     *
     * @param ticket
     * @return
     */
    int updateTicket(Ticket ticket);

    /**
     * 优惠券领用记录
     *
     * @param queryItem
     * @param status
     * @param centreId
     * @param ticketId
     * @param offset
     * @param limit
     * @return
     */
    PageUtils<TicketRecord> listRecords(Long centreId, String queryItem, Integer status, Long ticketId, Long judge, int offset, int limit);

    PageUtils<TicketRecord> listRecords(String ticketType, Long centreId, String queryItem, Integer status, Long ticketId, Long judge, int offset, int limit);

    /**
     * 发放优惠券给会员
     *
     * @param record
     * @return
     */
    int sendTicket(TicketRecord record);

    /**
     * 发放优惠券给新会员(新人券)
     *
     * @param mid      会员ID
     * @param num      发放数量
     * @param centreId 商户ID
     * @return
     */
    int sendNewMemberTicket(Long mid, Long centreId, Integer num);

    /**
     * 记录失效
     *
     * @param recordId
     * @return
     */
    int disableRecord(Long recordId);

    /**
     * 失效已经超过有效期的
     *
     * @return
     */
    int checkTicket();

    /**
     * 接近失效的优惠劵发模板
     *
     * @return
     */
    int sendTicketOvertimeMessage();

    /**
     * 通过订单参数获取满足条件的优惠券记录
     * @return
     */
    List<TicketRecord> getTicketRecords(OrderReq req, List<Long> productGradeIds);

    /**
     * 通过订单参数获取满足条件的优惠券记录
     *
     * @param mid
     * @param ops
     * @return
     */
    List<TicketRecord> getDetermineTicketRecords(Long mid, List<MemberCartVo> ops, Long teamId, Long industryBrandId, Long productGradeId, Long industryId);

    List<TicketRecord> getTicketRecordsJuHe(Long mid, String payMoney, Long teamId);

    /**
     * 获取会员优惠券记录
     *
     * @param mid    会员ID
     * @param status -1已失效，0-未使用，1-已使用
     * @param useFlag true 聚合支付查询使用列表（某些状态）   false 查询所有
     * @param offset
     * @param limit
     * @return
     */
    PageUtils<TicketRecord> listMidRecords(Long mid, Integer type, Integer status, Long industryBrandId, Long productGradeId, Long industryId, int offset, int limit);

    /**
     * 设置会员优惠券记录为未使用
     *
     * @param trId
     * @return
     */
    int updateRecordToNoUse(Long trId);

    /**
     * 更新会员优惠券记录
     *
     * @param tr
     * @return
     */
    int updateRecord(TicketRecord tr);

    /**
     * 会员优惠券详情
     *
     * @param trId
     * @return
     */
    TicketRecord getRecordByKey(Long trId);

    /**
     * 查询优惠券列表（是否可领用）
     */
    PageUtils<Map<String, Object>> couponList(Map<String, Object> map, int offset, int limit);

    /**
     * 新增优惠券领用记录
     */
    int saveTicketRecords(Ticket ticket, Long mId);

    /**
     * 查询该类型的优惠券
     *
     * @param rangeType
     * @return
     */
    Ticket getTicketRanType(int rangeType);

    /**
     * 获取新人优惠券
     *
     * @param centreid
     * @param state
     * @param memberid
     * @return
     */
    List<Ticket> getFirstLoginCoup(String centreid, Long memberid, Long teamId);

    /**
     * 获取未领取的优惠券
     *
     * @param centreid
     * @param memberid
     * @return
     */
    TicketVo getUncellectCoup(String centreid, String memberid);

    /**
     * 更新记录状态
     *
     * @param memberId
     * @param ticketid
     * @return
     */
    void updateRecord(Long memberId, List<String> ticketid);

    int sendTicketAll(TicketRecord record, Long userCentreId);

    /**
     * 判断大礼包卷是否充足
     *
     * @param activityId 大礼包id
     * @return void
     * @author liaozhaogui
     * @date 2021/4/1 10:48
     */
    void giftPacksTickets(Long activityId);

    /**
     * 判断拼团卷是否充足
     *
     * @param groupId 拼团id
     * @return void
     * @author liaozhaogui
     * @date 2021/4/1 11:26
     */
    void groupTickets(Long groupId);

    List<Ticket> queryList(Map params);

    PageUtils<Ticket> listTickets(String queryItem, Long centreId, Long teamId, Integer status, Integer activityType, Long activityId, Integer usableFlag, int offset, int limit);

    void settlementOrderSplitInfo(TicketRecord ticketRecord, Long ticketRecordUseId);

    int writeOffTicket(Member member, TicketParam ticketParam);

    void writeOffTicketList(Member member, TicketParam ticketParam);

    PageUtils<Ticket> listByFreecharge(String queryItem, Long centreId, Long teamId, Integer status, Integer activityType, Long activityId, int offset, int limit);

    PageUtils<TicketRecordUse> listRecordUsers(String ticketType, Long centreId, String queryItem, Integer status, Long ticketId, Long judge, int offset, int limit, Long teamId);

    PageUtils<TicketRecord> getLocalLifeCoupon(Long mid, Long ticketRecordId, int offset, int limit);

    PageUtils<Member> getLocalLifShopCoupon(Long memberId, Integer status, int offset, int limit);

    PageUtils<Member>  getOrderCouponList(Long orderid, int offset, int limit);

    /**
     * 判断大礼包券相关的大礼包订单是否在售后中
     */
    void giftPacksAfterSale(TicketRecord ticketRecord);
}
